$(document).ready(function() {
		
	getRadio();
		
});


//跳转到需要注册的页面表单进行注册操作
function startServiceRegister(){
	var selectValue = $('input[name="service"]:checked ').val();
	if(selectValue == 1){
		var bundleModel = $("#bundleModel_webservice").is(":checked");
		if(bundleModel){
			var wsdlAddress = $("#address").val();
			if(wsdlAddress != ""){
				var jsonData = {
						wsdlAddress:wsdlAddress
				}
				$("#progressbar, #progressbar_tips").fadeIn();
	  			loading_point.timer = setInterval(loading,200);
				$.ajax({
		  			type: "get",
		  			url: BASE_URL_HTTP_INTERFACE + '/getInterfaceCode' + '?v=' + Math.random(),
		  			dataType:'json',
		  			data: jsonData,
		  			contentType:"application/json",
		  			success: function(result) {
		  				$("#progressbar, #progressbar_tips").fadeOut();
						clearInterval(loading_point.timer);
		  				if(result.backValue === true){
			  				if(result.interfaceCodes == null || result.interfaceCodes == ""){
			  					$.messager.alert('info','<p>当前要注册的webservice中没有接口!</p>', 'info');
			  				}else{
				  				var interfaceCodes = result.interfaceCodes;
				  				//跳转到webservice代理模式服务注册页面
								window.location.href="webServiceRegistration.html?interfaceCodes=" + interfaceCodes + "&serviceType=" + selectValue + "&wsdlAddress=" + wsdlAddress + "&bundleModel=" + bundleModel;
			  				}
		  				}else if(result.backValue === false){
		  					$.messager.alert('错误','<p>'+ result.errorDes +'!</p>', 'error');
		  				}else{
		  					
		  				}
		  				
		  			},
		  			error: function() {
		  				$("#progressbar, #progressbar_tips").fadeOut();
						clearInterval(loading_point.timer);
		  				$.messager.alert('错误','<p>服务异常，获取接口编码失败，请稍后重试或联系管理员!</p>', 'error');
		  			}
		  		});
		  		
			}else{
				$.messager.alert('警告',"<p>接口原始地址不能为空!</p>","warning");
			}
		}else{
			//跳转到webservice自定义模式注册
			window.location.href="webServiceRegistration.html?serviceType=" + selectValue + "&bundleModel=" + bundleModel;
		}
	}else if(selectValue == 2){
		var bundleModel = $("#bundleModel_rest").is(":checked");
		var restAddress = ""; 
		if(bundleModel){
			//代理模式
			restAddress = $("#rest_address").val();
			if(restAddress == ""){
				$.messager.alert('警告',"<p>接口原始地址不能为空!</p>","warning");
			}else{
				//跳转到rest服务注册页面
				if(restAddress.indexOf("=") != -1){
					$.messager.confirm('温馨提示','<p>您填写的接口原始地址包含了参数，是否继续后面的操作?</p>',function(result){
						if(result){
							window.location.href="restApiRegistration.html?serviceType=" + selectValue + "&bundleModel=" + bundleModel+ "&restAddress=" + restAddress;
						}
					});
				}else{
					window.location.href="restApiRegistration.html?serviceType=" + selectValue + "&bundleModel=" + bundleModel+ "&restAddress=" + restAddress;
				}
			}
			
		}else{
			//自定义模式
			//跳转到rest服务注册页面
			window.location.href="restApiRegistration.html?serviceType=" + selectValue + "&bundleModel=" + bundleModel;
		}
		
	}else if(selectValue == 3){
		//跳转到ftp服务注册页面
		window.location.href="ftpRegistration.html?serviceType=" + selectValue;
	}else{
		
	}
		
	
}


function getRadio(){
	var selectValue = $('input[name="service"]:checked ').val();
	if(selectValue == 1){
		//var chooseVal = $("#comboxBundleModel").combobox('getValue');
		var chooseVal = $("#bundleModel_webservice").is(":checked");
		//alert("chooseVal:" + chooseVal);
		if(chooseVal){
			$("#input_con_webservice").show();
			$("#input_con_address").show();
			$("#input_con_rest").hide();
		}else{
			$("#input_con_webservice").show();
			$("#input_con_address").hide();
			$("#input_con_rest").hide();
		}
	}else if(selectValue == 2){
		var chooseVal = $("#bundleModel_rest").is(":checked");
		if(chooseVal){
			$("#input_con_webservice").hide();
			$("#input_con_address").hide();
			$("#input_con_rest").show();
			$("#input_con_rest_address").show();
			
		}else{
			$("#input_con_webservice").hide();
			$("#input_con_address").hide();
			$("#input_con_rest").show();
			$("#input_con_rest_address").hide();
		}
		
	}else{
		//alert("3");
		$("#input_con_webservice").hide();
		$("#input_con_address").hide();
		$("#input_con_rest").hide();
	}
	
	
}

$("#bundleModel_webservice").change(function(){
	var chooseVal = $("#bundleModel_webservice").is(":checked");
	//alert("chooseVal:" + chooseVal);
	if(chooseVal){
		$("#input_con_webservice").show();
		$("#input_con_address").show();
	}else{
		$("#input_con_webservice").show();
		$("#input_con_address").hide();
	}
});

$("#bundleModel_rest").change(function(){
	var chooseVal = $("#bundleModel_rest").is(":checked");
	//alert("chooseVal:" + chooseVal);
	if(chooseVal){
		$("#input_con_rest").show();
		$("#input_con_rest_address").show();
	}else{
		$("#input_con_rest").show();
		$("#input_con_rest_address").hide();
	}
});


var loading_point = {
		timer:null,
		len:3,
		count:0
	};
function loading()
{
 	if(loading_point.count < loading_point.len)
	{
		loading_point.count++;
		$("#progressbar_point").text($("#progressbar_point").text() + ".");
	}else
	{
		loading_point.count = 0;
		$("#progressbar_point").text("");
	}	
}


	